import datetime
import sqlite3


class SQLiteUtil:
    def __init__(self):
        self.conn = sqlite3.connect('conf/multi_info.db')
        self.cursor = self.conn.cursor()

    def insert_activation_code(self, parms):
        try:
            sql = 'insert into activation_code(device_id,activation_code) values(?,?) '
            self.cursor.execute(sql, parms)
            self.conn.commit()
        except Exception as e:
            print(e)

    def query_activation_code(self):
        try:
            sql = 'select activation_code from activation_code;'
            self.cursor.execute(sql)
            code = self.cursor.fetchone()
            return code[0]
        except Exception as e:
            print(e)


if __name__ == '__main__':
    sqllite = SQLiteUtil()
    # sqllite.create_table()
    # sqllite.drop_software_all()
    # row = ('QQ', 'D:\Program Files\Tencent\QQNT\QQ.exe', 3, datetime.datetime.now())
    # sqllite.add_softwareinfo(row)
    # r = sqllite.select_software_all()
    # print(r)
    code = sqllite.query_activation_code()
    print(code)
